# -*- coding: utf-8 -*-

# File Name： util
# Description :
# Author : lirui
# create_date： 2022/6/3
# Change Activity:
import math
import time

import torch


def int_to_tuple(v):
    """


    Args:
        v(int):

    Returns:

    """
    if isinstance(v, tuple):
        return v
    return v, v


def make_divisible(x, divisor):
    """
    Returns x evenly divisible by divisor

    Args:
        x: input
        divisor:

    Returns:

    """
    return math.ceil(x / divisor) * divisor


def time_sync():
    """
    pytorch-accurate time


    """
    if torch.cuda.is_available():
        torch.cuda.synchronize()
    return time.time()
